package com.linkhub.oms.admin.modules.pickuporder.domain.vo;

import com.linkhub.oms.admin.modules.pickuporder.domain.dto.EntryOrderLineExcelDTO;
import com.linkhub.oms.entity.resulttype.entryorder.EntryOrderLineResultEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * @Description: EntryOrderLineImportResultVO
 * @Author: echo
 * @Date: 2024/5/2 20:09
 * @Version: 1.0
 */
@Data
@ApiModel("EntryOrderLineImportResultVO")
public class EntryOrderLineImportResultVO implements Serializable {


    @ApiModelProperty(value = "本地商品skuId")
    private String skuId;

    @ApiModelProperty("sku")
    private String sku;

    @ApiModelProperty(value = "英文品名")
    private String productEnTitle;

    @ApiModelProperty(value = "数量")
    private Integer skuQuantity;

    @ApiModelProperty(value = "有效性标识")
    private boolean effectiveFlag;

    public static EntryOrderLineImportResultVO convert(EntryOrderLineResultEntity entity, EntryOrderLineExcelDTO excelDTO) {
        EntryOrderLineImportResultVO vo = new EntryOrderLineImportResultVO();
        vo.setSku(excelDTO.getSku());
        vo.setSkuQuantity(excelDTO.getQuantity());
        vo.setEffectiveFlag(false);

        if (Objects.nonNull(entity)) {
            vo.setSkuId(entity.getSkuId());
            vo.setProductEnTitle(entity.getProductEnTitle());
            vo.setEffectiveFlag(true);
        }

        return vo;

    }
}
